package main

import "fmt"

type method_a struct{
	//方法与字段的访问权限是以包为单位
	Name string
}

type method_b struct {
	Name string
}

func (a *method_a)method_print(){
	a.Name = "method_print_a"
	fmt.Println("A", a)
}

func (b method_b)method_print(){
	b.Name = "method_print_b"
	fmt.Println("B", b)
}

func main() {
	a := method_a{
		Name:"aaa",
	}
	b := method_b{
		Name:"bbb",
	}
	fmt.Println(a)
	fmt.Println(b)
	//编译器会自动在a前面添加&符号
	a.method_print()
	b.method_print()
	fmt.Println(a)
	fmt.Println(b)
}